package com.wdc.domain.activity.service.rule.factory;

import com.wdc.domain.activity.repository.IActivityRepository;
import com.wdc.domain.activity.service.rule.IActionChain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.stereotype.Service;

import javax.swing.plaf.PanelUI;
import java.util.Map;
import java.util.zip.DeflaterInputStream;

/**
 * 责任链工厂
 */
@Service
public class DefaultActionFactory {

    private final IActionChain actionChain;


    public DefaultActionFactory(Map<String, IActionChain> actionChainMap) {
        actionChain = actionChainMap.get(ActionModel.ACTIVITY_BASE_ACTION.code);
        actionChain.appendNext(actionChainMap.get(ActionModel.ACTIVITY_SKU_STOCK_ACTION.code));
    }

    /**
     * 构建责任链
     */
    public IActionChain openActionChain() {
        return actionChain;
    }


    @AllArgsConstructor
    @Getter
    public enum ActionModel {
        ACTIVITY_BASE_ACTION("activity_base_action", "活动的时间，状态校验"),
        ACTIVITY_SKU_STOCK_ACTION("activity_sku_stock_action", "活动sku库存");

        private final String code;
        private final String info;


    }
}
